class Aio::Module::OutputStyle::SnPrint < Aio::Module::OutputStyle

  include Aio::Ui::Verbose
  include Aio::Device

  def initialize
    super({
      :author		=> "Elin",
      :description	=> "这个模块是用来生成设备序列号的表",
      :file_suffix	=> "txt",
    })

    @report = []
    @file = nil

  end

  def generate
    @file = File.new(output_file, "w+")

    device_manager.devices.each_key do |device_name|
      device_klass = device_manager[device_name]
      generate_biref(device_klass)
    end

  ensure
    @file.close
  end

  def generate_biref(klass)
    hash = {}
    name = klass.device_name
    type = klass.device_type
    model = klass.device_info[:device_model]
    klass.inventory.each do |info|
        next if info[:sn].downcase.include?('none')
        str = format("%-20s %-5s %-20s %-20s %s", name, type, model, info[:pid], info[:sn])
        @file.write(str + "\n")
    end
  end

end
